<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>乐淘 - 后台管理</title>
    <link rel="stylesheet" href="./assets/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="./assets/font-awesome/css/font-awesome.css">
    <link rel="stylesheet" href="./assets/nprogress/nprogress.css">
    <link rel="stylesheet" href="./css/index.css">
</head>

<body>
    <!-- 登录 -->
    <div class="login">
        <div class="login-wrap">
            <div class="avatar">
                <img src="./uploads/monkey.png" class="img-circle" alt="">
            </div>
            <form action="" class="col-xs-offset-1 col-xs-10">
                <div class="input-group input-group-lg">
                    <span class="input-group-addon">
                        <i class="fa fa-user"></i>
                    </span>
                    <input type="text" name="username" class="form-control" placeholder="用户名">
                </div>
                <div class="input-group input-group-lg">
                    <span class="input-group-addon">
                        <i class="fa fa-key"></i>
                    </span>
                    <input type="password" name="password" class="form-control" placeholder="密码">
                </div>
                <button type="submit" class="btn btn-lg btn-primary btn-block">登 录</button>
            </form>
        </div>
    </div>

    <script src="./assets/jquery/jquery.min.js"></script>
    <script src="./assets/bootstrap/js/bootstrap.min.js"></script>
    <script src="/assets/vendors/jquery.form/jquery.form.js"></script>
    <script src="/assets/vendors/layer/layer.js"></script>
    <script>
        //获取url地址
        var url = location.search.slice(5);
        var newUrl = '';
        // console.log(url.length);
        if (url.length == 0) {
            newUrl = '/admin/index.html'
        } else {
            newUrl = url;
        }
        // console.log(newUrl);

        $('form').ajaxForm({
            url: '/api/employee/employeeLogin',
            type: 'post',
            success: function (msg) {
                if (msg.error) {
                    layer.msg('用户不存在!')
                    return;
                }
                if (msg.success) {
                    layer.msg('登录成功', {
                        shift: 5,
                        time: 500
                    }, function () {
                        location.href = newUrl;
                    })
                }
            }
        });


        
    </script>
</body>

</html>